package com.example.kotlindemo

/**
 *@time : 2021/1/22
 *@author :muzi102
 *@Description
 */
fun main() {
    var a = 1;
    var st1 = "a is $a"
    a = 10;
    val st2 = "${st1.replace("is", "was")},but now is $a"
    println(st2);
//    print("max of 42 and 56 is ${compareSize(42, 56)}")
    listString()
}

/*
比较大小
 */
fun compareSize(a: Int, b: Int): Int {
    return if (a > b) a else b
}


private fun listString() {
    val items = listOf<String>("康老师", "沈阳", "死神")
//    for (item in items) println(item)
    for (index in items.indices) println(" item at index is ${items[index]}")
}

private fun describe(obj: Any): String {
    return when (obj) {
        1 -> "one"
        "Hello" -> "greeting"
        is Long -> "Long"
        !is String -> "Not a String"
        else -> "Unknown"
    }
}